﻿var iMaxUpdateFileSize = 1024 * 1024 * 10;
function StartUploadify(objectid) {
    $("#" + objectid + '_Temp').uploadify({
        'uploader': '/Scripts/JqueryUploadify/uploadify.swf',
        'cancelImg': '/Scripts/JqueryUploadify/images/cancel.png',
        'buttonText': 'Select',
       'buttonImg': '/Scripts/JqueryUploadify/images/attach.png',
         'width': 22,
         'height': 22,
        'folder':'Uploads',
        'script': '/RemoteHandlers/Upload.ashx',
        'fileExt': '*.jpg;*.jpeg;*.gif;*.png;*.doc;*.docx;*.xls;*.xlsx;*.pdf;*.txt',
        'sizeLimit': iMaxUpdateFileSize,
        'simUploadLimit': 10,
        'multi': false,
        'auto': true,
        'onSelect': function (a, b, c) { /*选择文件上传时可以禁用某些按钮*/ },
        'onComplete': function (a, b, c, d, e) { SetLi_UpdateFiles(objectid, c,d); },
        'onAllComplete': function (a, b) {
            enabledSaveButton(true);
        },
        'onCancel': function (a, b, c, d, e) { },
        'onError': function (a, b, c, d, e) {
            if (c.size > iMaxUpdateFileSize) {
                setTimeout("$('#'+objectid+'_Temp').uploadifyCancel('" + b + "')", 2000);
            }
        }
    });
}

function SetLi_UpdateFiles(objectid, objFile,d) {
    $("input[name='" + objectid + "']").val(d);
    $("img[id='" + objectid + "']").attr("src", d);
    $("a[id='" + objectid + "']").attr("href", d);
    $("a[id='" + objectid + "']").html(d);
}

